<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><title>numpy | zylai</title><meta name="keywords" content="python数据分析"><meta name="author" content="zylai"><meta name="copyright" content="zylai"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="numpy 0、作用 使用numpy&amp;pandas使得数据分析中计算非常快，比python自带的字典和列表快很多，因为这俩模块使用C语言编写的。应用到了矩阵的运算，使用C语言实现，更快。 1、安装 直接在终端使用命令 1pip install numpy 安装完成即可 2、numpy基本属性 基本属性包括：将列表转换为numpy的array，查看array的维度、形状、总元素个数 1234">
<meta property="og:type" content="article">
<meta property="og:title" content="numpy">
<meta property="og:url" content="https://zhaoyunlai.gitee.io/posts/ee38083b3187/index.html">
<meta property="og:site_name" content="zylai">
<meta property="og:description" content="numpy 0、作用 使用numpy&amp;pandas使得数据分析中计算非常快，比python自带的字典和列表快很多，因为这俩模块使用C语言编写的。应用到了矩阵的运算，使用C语言实现，更快。 1、安装 直接在终端使用命令 1pip install numpy 安装完成即可 2、numpy基本属性 基本属性包括：将列表转换为numpy的array，查看array的维度、形状、总元素个数 1234">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_gif%2Fptp8P184xjyNYtPWdCkYyJrGRibqWpKXflz2vKmsNVmLV4sYmAHN0CUQ7AqrkShBE4fOyeHAhSJicaX7UgxHXlPw%2F640%3Fwx_fmt%3Dgif&refer=http%3A%2F%2Fmmbiz.qpic.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1653547607&t=8c6a499edf55691baed0949ed7465a71">
<meta property="article:published_time" content="2022-03-07T13:59:07.000Z">
<meta property="article:modified_time" content="2022-08-27T08:23:39.754Z">
<meta property="article:author" content="zylai">
<meta property="article:tag" content="python数据分析">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_gif%2Fptp8P184xjyNYtPWdCkYyJrGRibqWpKXflz2vKmsNVmLV4sYmAHN0CUQ7AqrkShBE4fOyeHAhSJicaX7UgxHXlPw%2F640%3Fwx_fmt%3Dgif&refer=http%3A%2F%2Fmmbiz.qpic.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1653547607&t=8c6a499edf55691baed0949ed7465a71"><link rel="shortcut icon" href="/img/favicon.png"><link rel="canonical" href="https://zhaoyunlai.gitee.io/posts/ee38083b3187/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//hm.baidu.com"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.min.css" media="print" onload="this.media='all'"><script>var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?ec7714e43e379e663d7258bb72abd0cc";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: {"path":"/search.xml","preload":false,"languages":{"hits_empty":"找不到您查询的内容：${query}"}},
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isAnchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'numpy',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2022-08-27 16:23:39'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><!-- hexo injector head_end start --><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/Zfour/hexo-electric-clock@1.0.6/clock.css"><!-- hexo injector head_end end --><meta name="generator" content="Hexo 5.4.2"></head><body><div id="web_bg"></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="/img/avatar.jpg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">18</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">14</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">11</div></a></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_gif%2Fptp8P184xjyNYtPWdCkYyJrGRibqWpKXflz2vKmsNVmLV4sYmAHN0CUQ7AqrkShBE4fOyeHAhSJicaX7UgxHXlPw%2F640%3Fwx_fmt%3Dgif&amp;refer=http%3A%2F%2Fmmbiz.qpic.cn&amp;app=2002&amp;size=f9999,10000&amp;q=a80&amp;n=0&amp;g=0n&amp;fmt=auto?sec=1653547607&amp;t=8c6a499edf55691baed0949ed7465a71')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">zylai</a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">numpy</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2022-03-07T13:59:07.000Z" title="发表于 2022-03-07 21:59:07">2022-03-07</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2022-08-27T08:23:39.754Z" title="更新于 2022-08-27 16:23:39">2022-08-27</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/python/">python</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="numpy"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h1>numpy</h1>
<h2 id="0、作用">0、作用</h2>
<p>使用numpy&amp;pandas使得数据分析中计算非常快，比python自带的字典和列表快很多，因为这俩模块使用C语言编写的。应用到了矩阵的运算，使用C语言实现，更快。</p>
<h2 id="1、安装">1、安装</h2>
<p>直接在终端使用命令</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">pip install numpy</span><br></pre></td></tr></table></figure>
<p>安装完成即可</p>
<h2 id="2、numpy基本属性">2、numpy基本属性</h2>
<p>基本属性包括：将列表转换为numpy的array，查看array的维度、形状、总元素个数</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> numpy <span class="keyword">as</span> np <span class="comment">#一般习惯重命名为np</span></span><br><span class="line"><span class="comment"># 将列表转换为numpy的矩阵</span></span><br><span class="line">array = np.array([[<span class="number">1</span>,<span class="number">2</span>,<span class="number">3</span>],[<span class="number">2</span>,<span class="number">3</span>,<span class="number">4</span>]])</span><br><span class="line"><span class="built_in">print</span>(array)</span><br><span class="line"><span class="comment"># 维度</span></span><br><span class="line"><span class="built_in">print</span>(<span class="string">&#x27;number of dimation: &#x27;</span>,array.ndim)</span><br><span class="line"><span class="comment"># 形状</span></span><br><span class="line"><span class="built_in">print</span>(<span class="string">&#x27;shape:&#x27;</span>,array.shape)</span><br><span class="line"><span class="comment"># 总共多少个元素在矩阵中</span></span><br><span class="line"><span class="built_in">print</span>(<span class="string">&#x27;size:&#x27;</span>,array.size)</span><br></pre></td></tr></table></figure>
<h2 id="3、创建">3、创建</h2>
<p>创建的方法有：</p>
<ol>
<li>直接传入列表</li>
<li>通过zeros()方法生成全为0的矩阵</li>
<li>通过ones()方法生成全为1的矩阵</li>
<li>通过empty()方法生成全为0的矩阵</li>
<li>通过arange()方法生成有序array</li>
<li>使用reshape指定形状，注意，元素个数可以变成指定的形状否则报错</li>
<li>linspace分段</li>
<li>使用random模块，生成随机的。随机数位于0到1之间</li>
</ol>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> numpy <span class="keyword">as</span> np</span><br><span class="line"><span class="comment"># 1,直接传入列表，使用的type指定数据类型，比如float32，几位数字需要根据精度需求来确定</span></span><br><span class="line"><span class="comment"># 位数越大，精度越高但同时占用空间越大</span></span><br><span class="line">a = np.array([[<span class="number">2</span>,<span class="number">3</span>,<span class="number">4</span>],[<span class="number">3</span>,<span class="number">4</span>,<span class="number">5</span>]],dtype=np.float32)</span><br><span class="line"><span class="comment"># 打印出来，和列表的差别就是，没有逗号</span></span><br><span class="line"><span class="built_in">print</span>(a)</span><br><span class="line"><span class="built_in">print</span>(a.dtype)</span><br><span class="line"></span><br><span class="line"><span class="comment"># 2,直接生成全部为0的矩阵,需要在参数中传入形状（用一个括号包着)</span></span><br><span class="line"><span class="comment"># 如果不指定数据类型，zeros默认为float64</span></span><br><span class="line">b = np.zeros((<span class="number">3</span>,<span class="number">4</span>))</span><br><span class="line"><span class="built_in">print</span>(b)</span><br><span class="line"><span class="comment"># 同理，生成全为1的，使用ones方法即可</span></span><br><span class="line">b = np.ones((<span class="number">4</span>,<span class="number">5</span>),dtype=np.int16)</span><br><span class="line"><span class="built_in">print</span>(b)</span><br><span class="line"></span><br><span class="line"><span class="comment"># 3,empty,相当于生成全为0的</span></span><br><span class="line">c = np.empty((<span class="number">3</span>,<span class="number">4</span>))</span><br><span class="line"><span class="built_in">print</span>(c)</span><br><span class="line"></span><br><span class="line"><span class="comment"># 4，生成有序，和python中的arange相同，指定区间（左闭右开），指定步长</span></span><br><span class="line"><span class="comment"># 步长为2,10到20之间</span></span><br><span class="line">c = np.arange(<span class="number">10</span>,<span class="number">21</span>,<span class="number">2</span>)</span><br><span class="line"><span class="built_in">print</span>(c)</span><br><span class="line"></span><br><span class="line"><span class="comment"># 5，使用reshape指定形状，注意，元素个数可以变成指定的形状否则报错</span></span><br><span class="line">c = np.arange(<span class="number">12</span>).reshape((<span class="number">3</span>,<span class="number">4</span>))</span><br><span class="line"><span class="built_in">print</span>(c)</span><br><span class="line"></span><br><span class="line"><span class="comment"># 6，linspace分段，在闭区间1到10中生成5个点，平均分成4段</span></span><br><span class="line">a = np.linspace(<span class="number">0</span>,<span class="number">10</span>,<span class="number">5</span>)</span><br><span class="line"><span class="built_in">print</span>(a)</span><br><span class="line"></span><br><span class="line"><span class="comment"># 7、使用random模块，生成随机的。随机数位于0到1之间</span></span><br><span class="line">a = np.random.random((<span class="number">2</span>,<span class="number">4</span>))</span><br><span class="line"><span class="built_in">print</span>(a)</span><br></pre></td></tr></table></figure>
<h2 id="4、运算">4、运算</h2>
<ol>
<li>加法、减法、指数运算、三角函数运算、布尔值运算。都是对每个元素都进行运算</li>
<li>矩阵乘法</li>
<li>
<ul>
<li>逐个元素相乘</li>
<li>使用dot方法矩阵相乘（线性代数的知识）</li>
</ul>
</li>
<li>求和，求最大值最小值，都是返回一个指定的元素</li>
<li>求指定维度的和、最大最小值，需要根据axis指定维度</li>
</ol>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> numpy <span class="keyword">as</span> np</span><br><span class="line">a = np.array([<span class="number">10</span>,<span class="number">20</span>,<span class="number">30</span>,<span class="number">40</span>])</span><br><span class="line">b = np.arange(<span class="number">4</span>)</span><br><span class="line"><span class="built_in">print</span>(a,b)</span><br><span class="line"><span class="comment"># 1、减法</span></span><br><span class="line"><span class="built_in">print</span>(a-b)</span><br><span class="line"><span class="comment"># 2、加法</span></span><br><span class="line"><span class="built_in">print</span>(a+b)</span><br><span class="line"><span class="comment"># 3、指数</span></span><br><span class="line"><span class="built_in">print</span>(a**<span class="number">2</span>)</span><br><span class="line"><span class="comment"># 4、三角函数运算</span></span><br><span class="line"><span class="comment"># print(np.sin(a),np.cos(a),np.tan(a))</span></span><br><span class="line"><span class="comment"># 5、布尔值</span></span><br><span class="line"><span class="built_in">print</span>(b)</span><br><span class="line"><span class="built_in">print</span>(b&lt;<span class="number">3</span>)</span><br><span class="line"><span class="built_in">print</span>(b==<span class="number">3</span>)</span><br><span class="line"></span><br><span class="line"><span class="comment">############矩阵###########</span></span><br><span class="line">a = np.array([[<span class="number">10</span>,<span class="number">20</span>],[<span class="number">30</span>,<span class="number">45</span>]])</span><br><span class="line">b = np.arange(<span class="number">4</span>).reshape((<span class="number">2</span>,<span class="number">2</span>))</span><br><span class="line"><span class="built_in">print</span>(a)</span><br><span class="line"><span class="built_in">print</span>(b)</span><br><span class="line"><span class="comment"># 乘法，逐个相乘</span></span><br><span class="line"><span class="built_in">print</span>(a*b)</span><br><span class="line"><span class="comment"># 乘法，矩阵相乘，使用np.dot或者a.dot(b)</span></span><br><span class="line"><span class="built_in">print</span>(np.dot(a,b))</span><br><span class="line"><span class="built_in">print</span>(a.dot(b))</span><br><span class="line"></span><br><span class="line"><span class="comment"># 随机生成一个矩阵</span></span><br><span class="line">a = np.random.random((<span class="number">2</span>,<span class="number">4</span>))</span><br><span class="line"><span class="built_in">print</span>(a)</span><br><span class="line"><span class="comment"># 求和，或者写成a.sum()</span></span><br><span class="line"><span class="built_in">print</span>(np.<span class="built_in">sum</span>(a))</span><br><span class="line"><span class="comment"># 最大值</span></span><br><span class="line"><span class="built_in">print</span>(np.<span class="built_in">max</span>(a))</span><br><span class="line"><span class="comment"># 最小值</span></span><br><span class="line"><span class="built_in">print</span>(np.<span class="built_in">min</span>(a))</span><br><span class="line"><span class="comment"># 求指定维度的和，最大最小值</span></span><br><span class="line"><span class="comment"># axis为1，就是将维度为1的元素累加，该维度消失，只剩下维度为0的行</span></span><br><span class="line"><span class="built_in">print</span>(np.<span class="built_in">sum</span>(a,axis=<span class="number">1</span>))</span><br><span class="line"><span class="built_in">print</span>(np.<span class="built_in">max</span>(a,axis=<span class="number">1</span>))</span><br><span class="line"><span class="built_in">print</span>(np.<span class="built_in">min</span>(a,axis=<span class="number">0</span>))</span><br><span class="line"><span class="comment"># 另一种写法</span></span><br><span class="line"><span class="built_in">print</span>(a.<span class="built_in">min</span>(axis=<span class="number">0</span>))</span><br><span class="line"><span class="comment"># 总结，axis的值为求和的维度，运算之后该维度消失</span></span><br></pre></td></tr></table></figure>
<h2 id="5、运算2">5、运算2</h2>
<ol>
<li>求最小最大值索引</li>
<li>求平均值，指定维度求平均值</li>
<li>求中位数</li>
<li>累加，第n个元素为原矩阵前n个元素的和</li>
<li>累差，原矩阵相邻元素之间的差值，列数减一</li>
<li>找出非0的元素，返回的值是多个表示非零元素的维度数组，数组拼接即可得到非零元素的索引值</li>
<li>排序，按照最小的维度排序，对于矩阵就是对行内的列元素排序</li>
<li>转置矩阵</li>
</ol>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> numpy <span class="keyword">as</span> np</span><br><span class="line">A = np.arange(<span class="number">2</span>,<span class="number">14</span>).reshape((<span class="number">3</span>,<span class="number">4</span>))</span><br><span class="line"><span class="built_in">print</span>(A)</span><br><span class="line"><span class="comment"># 最小值索引，两种写法都可</span></span><br><span class="line"><span class="built_in">print</span>(np.argmin(A))</span><br><span class="line"><span class="built_in">print</span>(A.argmin())</span><br><span class="line"><span class="comment"># 最大值索引</span></span><br><span class="line"><span class="built_in">print</span>(A.argmax())</span><br><span class="line"><span class="comment"># 求平均值</span></span><br><span class="line"><span class="built_in">print</span>(A.mean())</span><br><span class="line"><span class="comment"># 也可以指定维度</span></span><br><span class="line"><span class="built_in">print</span>(np.mean(A,axis=<span class="number">0</span>))</span><br><span class="line"><span class="built_in">print</span>(np.average(A))</span><br><span class="line"><span class="comment"># 不能这样使用average</span></span><br><span class="line"><span class="comment"># print(A.average())</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 求中位数,也是只能np.median</span></span><br><span class="line"><span class="built_in">print</span>(np.median(A))</span><br><span class="line"><span class="comment"># 累加,第n个元素为原矩阵前n个元素的和</span></span><br><span class="line"><span class="built_in">print</span>(np.cumsum(A))</span><br><span class="line"><span class="comment"># 累差，原矩阵相邻元素之间的差值，列数减一了，因为n个元素有n-1个差值</span></span><br><span class="line"><span class="built_in">print</span>(np.diff(A))</span><br><span class="line"><span class="comment"># 找出非零元素，返回维度的数组</span></span><br><span class="line"><span class="built_in">print</span>(np.nonzero(A))</span><br><span class="line"></span><br><span class="line"><span class="comment"># 排序，最小的那个维度的数进行排序。如果是矩阵，就是行内的每列元素进行排序</span></span><br><span class="line">B = np.arange(<span class="number">14</span>,<span class="number">2</span>,-<span class="number">1</span>).reshape((<span class="number">3</span>,<span class="number">4</span>))</span><br><span class="line"><span class="built_in">print</span>(B)</span><br><span class="line"><span class="comment"># 不会改变原矩阵的值</span></span><br><span class="line"><span class="built_in">print</span>(np.sort(B))</span><br><span class="line"></span><br><span class="line"><span class="comment"># 矩阵的转置，行变成列，列变成行</span></span><br><span class="line"><span class="built_in">print</span>(np.transpose(B))</span><br><span class="line"><span class="built_in">print</span>(B.T)</span><br><span class="line"><span class="built_in">print</span>((B.T).dot(B))</span><br><span class="line"></span><br><span class="line"><span class="comment"># clip，所有大于9的数都变成9，小于5的数都变成5,5到9之间的数不变</span></span><br><span class="line"><span class="built_in">print</span>(B)</span><br><span class="line"><span class="built_in">print</span>(np.clip(B,<span class="number">5</span>,<span class="number">9</span>))</span><br></pre></td></tr></table></figure>
<h2 id="6、索引">6、索引</h2>
<ol>
<li>对于多维的索引，索引号都放在一个中括号中，用逗号分割开</li>
<li>切片</li>
<li>for迭代，默认迭代矩阵的行</li>
</ol>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> numpy <span class="keyword">as</span> np</span><br><span class="line"></span><br><span class="line">A = np.arange(<span class="number">3</span>,<span class="number">15</span>).reshape((<span class="number">3</span>,<span class="number">4</span>))</span><br><span class="line"><span class="built_in">print</span>(A)</span><br><span class="line"><span class="built_in">print</span>(A[<span class="number">2</span>])</span><br><span class="line"><span class="built_in">print</span>(A[<span class="number">2</span>][<span class="number">1</span>])</span><br><span class="line"><span class="comment"># 多维索引都放在一个中括号中，用逗号分割</span></span><br><span class="line"><span class="built_in">print</span>(A[<span class="number">2</span>,<span class="number">1</span>])</span><br><span class="line"></span><br><span class="line"><span class="comment"># 切片</span></span><br><span class="line"><span class="comment"># 第一维度所有元素，就是原矩阵</span></span><br><span class="line"><span class="built_in">print</span>(A[:])</span><br><span class="line"><span class="comment"># 第一维度不限定，第二维度索引为1</span></span><br><span class="line"><span class="built_in">print</span>(A[:,<span class="number">1</span>])</span><br><span class="line"><span class="comment"># 切片限定第二维度（列）</span></span><br><span class="line"><span class="built_in">print</span>(A[<span class="number">1</span>,<span class="number">1</span>:<span class="number">3</span>])</span><br><span class="line"><span class="built_in">print</span>(<span class="string">&quot;********************&quot;</span>)</span><br><span class="line"></span><br><span class="line"><span class="comment"># for迭代，默认迭代矩阵的行。就是第一维度</span></span><br><span class="line"><span class="keyword">for</span> row <span class="keyword">in</span> A:</span><br><span class="line">    <span class="built_in">print</span>(row)</span><br><span class="line"><span class="comment"># 迭代矩阵的列，可以通过迭代转置矩阵的列</span></span><br><span class="line"><span class="keyword">for</span> col <span class="keyword">in</span> A.T:</span><br><span class="line">    <span class="built_in">print</span>(col)</span><br><span class="line"><span class="comment"># 迭代每一个元素,flat之后是一个一维的列表</span></span><br><span class="line"><span class="keyword">for</span> item <span class="keyword">in</span> A.flat:</span><br><span class="line">    <span class="built_in">print</span>(item,end=<span class="string">&#x27;,&#x27;</span>)</span><br></pre></td></tr></table></figure>
<h2 id="7、array合并">7、array合并</h2>
<ol>
<li>使用vstack实现多个array上下合并</li>
<li>使用hstack实现多个array水平合并</li>
<li>把一个横向的数列变成纵向的数列</li>
<li>使用concatenate多个array的合并指定合并的维度</li>
</ol>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> numpy <span class="keyword">as</span> np</span><br><span class="line">A = np.array([<span class="number">1</span>,<span class="number">1</span>,<span class="number">1</span>])</span><br><span class="line">B = np.array([<span class="number">2</span>,<span class="number">2</span>,<span class="number">2</span>])</span><br><span class="line"></span><br><span class="line"><span class="comment"># 上下合并</span></span><br><span class="line">C = np.vstack((A,B))</span><br><span class="line"><span class="built_in">print</span>(C)</span><br><span class="line"><span class="built_in">print</span>(A.shape,C.shape)</span><br><span class="line"></span><br><span class="line"><span class="comment"># 左右合并（水平合并） horizontal stack</span></span><br><span class="line">D = np.hstack((A,B))</span><br><span class="line"><span class="built_in">print</span>(D)</span><br><span class="line"><span class="built_in">print</span>(A.shape,D.shape)</span><br><span class="line"></span><br><span class="line"><span class="built_in">print</span>(<span class="string">&quot;*********************&quot;</span>)</span><br><span class="line"><span class="comment"># 如何把一个横向的数列变成纵向的数列</span></span><br><span class="line">A = A[:,np.newaxis]</span><br><span class="line">B = B[:,np.newaxis]</span><br><span class="line"><span class="built_in">print</span>(A.shape,B.shape)</span><br><span class="line"><span class="comment"># 左右合并，hstack和vstack都可以进行多个array的合并</span></span><br><span class="line">D = np.hstack((A,B,B))</span><br><span class="line"><span class="built_in">print</span>(D)</span><br><span class="line"></span><br><span class="line"><span class="comment"># 多个array的合并指定合并的维度，和上面两个不同的就是可以指定合并的维度</span></span><br><span class="line"><span class="comment"># 比如，在第一维度合并，即合并行</span></span><br><span class="line">C = np.concatenate((A,B,B,A),axis=<span class="number">0</span>)</span><br><span class="line"><span class="built_in">print</span>(C)</span><br><span class="line"><span class="comment"># 合并列</span></span><br><span class="line"><span class="built_in">print</span>(np.concatenate((A,B,B,A),axis=<span class="number">1</span>))</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<h2 id="8、分割">8、分割</h2>
<ol>
<li>使用split均等分割</li>
<li>使用array_split不均等分割</li>
<li>使用vsplit和hsplit进行均等分割</li>
</ol>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> numpy <span class="keyword">as</span> np</span><br><span class="line"></span><br><span class="line">A = np.arange(<span class="number">12</span>).reshape((<span class="number">3</span>,<span class="number">4</span>))</span><br><span class="line"><span class="built_in">print</span>(A)</span><br><span class="line"><span class="comment"># 均等分割，使用split均等分割</span></span><br><span class="line"><span class="built_in">print</span>(np.split(A,<span class="number">2</span>,axis=<span class="number">1</span>))</span><br><span class="line"><span class="built_in">print</span>(np.split(A,<span class="number">3</span>,axis=<span class="number">0</span>))</span><br><span class="line"></span><br><span class="line"><span class="comment"># 不均等分割，使用array_split</span></span><br><span class="line"><span class="comment"># 这里将四列分为三部分，第一部分为2列，2,3部分为1列</span></span><br><span class="line"><span class="built_in">print</span>(np.array_split(A,<span class="number">3</span>,axis=<span class="number">1</span>))</span><br><span class="line"><span class="comment"># 使用vsplit和hsplit进行分割</span></span><br><span class="line"><span class="built_in">print</span>(np.vsplit(A,<span class="number">3</span>))</span><br><span class="line"><span class="built_in">print</span>(np.hsplit(A,<span class="number">2</span>))</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<h2 id="9、copy和deep-copy">9、copy和deep copy</h2>
<ol>
<li>通过 = 赋值的变量都指向同一个数据</li>
<li>使用copy方法使复制后两个变量不相关联</li>
</ol>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> numpy <span class="keyword">as</span> np</span><br><span class="line">a = np.arange(<span class="number">4</span>)</span><br><span class="line"><span class="built_in">print</span>(a)</span><br><span class="line">b = a</span><br><span class="line">c = a</span><br><span class="line">d = b</span><br><span class="line"><span class="comment"># 目前为止，abcd都是一样</span></span><br><span class="line"><span class="comment"># 这里更改a的值，观察其他变量的改变</span></span><br><span class="line">a[<span class="number">0</span>]=<span class="number">11</span></span><br><span class="line"><span class="built_in">print</span>(a,b,c,d)</span><br><span class="line"><span class="built_in">print</span>(b <span class="keyword">is</span> a,c <span class="keyword">is</span> a,d <span class="keyword">is</span> a)</span><br><span class="line"><span class="comment"># 可以看到，改变了a，bcd都会改变，哪怕是通过b赋值的d</span></span><br><span class="line"><span class="comment"># 同理，改变了bcd任何一个元素，a的值也会改变</span></span><br><span class="line"><span class="comment"># 所以，通过=赋值的变量都是指向同一个数据，是浅拷贝</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 如果想让赋值后的两个变量不相关联，使用copy()方法</span></span><br><span class="line">e = a.copy()</span><br><span class="line"><span class="built_in">print</span>(e <span class="keyword">is</span> a)</span><br><span class="line">a[<span class="number">1</span>]=<span class="number">22</span></span><br><span class="line"><span class="built_in">print</span>(a,e)</span><br></pre></td></tr></table></figure></article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="https://zhaoyunlai.gitee.io">zylai</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://zhaoyunlai.gitee.io/posts/ee38083b3187/">https://zhaoyunlai.gitee.io/posts/ee38083b3187/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://zhaoyunlai.gitee.io" target="_blank">zylai</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/python%E6%95%B0%E6%8D%AE%E5%88%86%E6%9E%90/">python数据分析</a></div><div class="post_share"><div class="social-share" data-image="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_gif%2Fptp8P184xjyNYtPWdCkYyJrGRibqWpKXflz2vKmsNVmLV4sYmAHN0CUQ7AqrkShBE4fOyeHAhSJicaX7UgxHXlPw%2F640%3Fwx_fmt%3Dgif&amp;refer=http%3A%2F%2Fmmbiz.qpic.cn&amp;app=2002&amp;size=f9999,10000&amp;q=a80&amp;n=0&amp;g=0n&amp;fmt=auto?sec=1653547607&amp;t=8c6a499edf55691baed0949ed7465a71" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/posts/8dfe3ff98cbb/"><img class="prev-cover" src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fwww.geocalculate.com%2Fwp-content%2Fuploads%2F2020%2F07%2Fpandas.png&amp;refer=http%3A%2F%2Fwww.geocalculate.com&amp;app=2002&amp;size=f9999,10000&amp;q=a80&amp;n=0&amp;g=0n&amp;fmt=auto?sec=1653547694&amp;t=2523b5ca63fc839243af3a93c7c2ba71" onerror="onerror=null;src='/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">pandas</div></div></a></div><div class="next-post pull-right"><a href="/posts/f3f577588565/"><img class="next-cover" src="https://zh-v2.d2l.ai/_images/front.png" onerror="onerror=null;src='/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">Windows上配置深度学习</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span>相关推荐</span></div><div class="relatedPosts-list"><div><a href="/posts/8dfe3ff98cbb/" title="pandas"><img class="cover" src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fwww.geocalculate.com%2Fwp-content%2Fuploads%2F2020%2F07%2Fpandas.png&refer=http%3A%2F%2Fwww.geocalculate.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1653547694&t=2523b5ca63fc839243af3a93c7c2ba71" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-03-08</div><div class="title">pandas</div></div></a></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="/img/avatar.jpg" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">zylai</div><div class="author-info__description">zylai && 管大虾の克星</div></div><div class="card-info-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">18</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">14</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">11</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/zhaoyunlai"><i class="fab fa-github"></i><span>Follow Me</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/zhaoyunlai" target="_blank" title="Github"><i class="fab fa-github"></i></a><a class="social-icon" href="mailto:zylai0712@163.com" target="_blank" title="Email"><i class="fas fa-envelope"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">This is my blog</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link"><span class="toc-text">numpy</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#0%E3%80%81%E4%BD%9C%E7%94%A8"><span class="toc-text">0、作用</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#1%E3%80%81%E5%AE%89%E8%A3%85"><span class="toc-text">1、安装</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2%E3%80%81numpy%E5%9F%BA%E6%9C%AC%E5%B1%9E%E6%80%A7"><span class="toc-text">2、numpy基本属性</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#3%E3%80%81%E5%88%9B%E5%BB%BA"><span class="toc-text">3、创建</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#4%E3%80%81%E8%BF%90%E7%AE%97"><span class="toc-text">4、运算</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#5%E3%80%81%E8%BF%90%E7%AE%972"><span class="toc-text">5、运算2</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#6%E3%80%81%E7%B4%A2%E5%BC%95"><span class="toc-text">6、索引</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#7%E3%80%81array%E5%90%88%E5%B9%B6"><span class="toc-text">7、array合并</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#8%E3%80%81%E5%88%86%E5%89%B2"><span class="toc-text">8、分割</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#9%E3%80%81copy%E5%92%8Cdeep-copy"><span class="toc-text">9、copy和deep copy</span></a></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/posts/22ef9dff46af/" title="移动互联网开发技术-第三次实验"><img src="https://zylai-cloud-pic-1306915061.cos.ap-nanjing.myqcloud.com/images01/%E7%B3%BB%E7%BB%9F%E8%AE%BE%E8%AE%A1.assets/sdnu-background2.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="移动互联网开发技术-第三次实验"/></a><div class="content"><a class="title" href="/posts/22ef9dff46af/" title="移动互联网开发技术-第三次实验">移动互联网开发技术-第三次实验</a><time datetime="2022-10-15T01:43:30.000Z" title="发表于 2022-10-15 09:43:30">2022-10-15</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/posts/85838fb07a8b/" title="学生成长动态追踪系统-学生使用手册"><img src="https://zylai-cloud-pic-1306915061.cos.ap-nanjing.myqcloud.com/images01/%E7%B3%BB%E7%BB%9F%E8%AE%BE%E8%AE%A1.assets/sdnu-background2.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="学生成长动态追踪系统-学生使用手册"/></a><div class="content"><a class="title" href="/posts/85838fb07a8b/" title="学生成长动态追踪系统-学生使用手册">学生成长动态追踪系统-学生使用手册</a><time datetime="2022-09-25T11:43:30.000Z" title="发表于 2022-09-25 19:43:30">2022-09-25</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/posts/896511b44bb7/" title="学生成长动态追踪系统-家长使用手册"><img src="https://zylai-cloud-pic-1306915061.cos.ap-nanjing.myqcloud.com/images01/%E7%B3%BB%E7%BB%9F%E8%AE%BE%E8%AE%A1.assets/sdnu-background2.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="学生成长动态追踪系统-家长使用手册"/></a><div class="content"><a class="title" href="/posts/896511b44bb7/" title="学生成长动态追踪系统-家长使用手册">学生成长动态追踪系统-家长使用手册</a><time datetime="2022-09-25T11:43:29.000Z" title="发表于 2022-09-25 19:43:29">2022-09-25</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/posts/78afc3f0ab42/" title="Shiro权限安全框架的使用"><img src="https://zylai-cloud-pic-1306915061.cos.ap-nanjing.myqcloud.com/images01/shiro.assets/image-20220929162947122.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Shiro权限安全框架的使用"/></a><div class="content"><a class="title" href="/posts/78afc3f0ab42/" title="Shiro权限安全框架的使用">Shiro权限安全框架的使用</a><time datetime="2022-09-18T11:43:29.000Z" title="发表于 2022-09-18 19:43:29">2022-09-18</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/posts/e32230f09e09/" title="学生成长动态追踪系统"><img src="https://zylai-cloud-pic-1306915061.cos.ap-nanjing.myqcloud.com/images01/%E7%B3%BB%E7%BB%9F%E8%AE%BE%E8%AE%A1.assets/sdnu-background2.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="学生成长动态追踪系统"/></a><div class="content"><a class="title" href="/posts/e32230f09e09/" title="学生成长动态追踪系统">学生成长动态追踪系统</a><time datetime="2022-08-25T11:43:29.000Z" title="发表于 2022-08-25 19:43:29">2022-08-25</time></div></div></div></div></div></div></main><footer id="footer" style="background-image: url('https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_gif%2Fptp8P184xjyNYtPWdCkYyJrGRibqWpKXflz2vKmsNVmLV4sYmAHN0CUQ7AqrkShBE4fOyeHAhSJicaX7UgxHXlPw%2F640%3Fwx_fmt%3Dgif&amp;refer=http%3A%2F%2Fmmbiz.qpic.cn&amp;app=2002&amp;size=f9999,10000&amp;q=a80&amp;n=0&amp;g=0n&amp;fmt=auto?sec=1653547607&amp;t=8c6a499edf55691baed0949ed7465a71')"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2022 By zylai</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div id="local-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><span id="loading-status"></span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="is-center" id="loading-database"><i class="fas fa-spinner fa-pulse"></i><span>  数据库加载中</span></div><div class="search-wrap"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div><hr/><div id="local-search-results"></div></div></div><div id="search-mask"></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.umd.min.js"></script><script src="/js/search/local-search.js"></script><div class="js-pjax"></div><script defer="defer" id="ribbon" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/dist/canvas-ribbon.min.js" size="150" alpha="0.6" zIndex="-1" mobile="false" data-click="true"></script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div><!-- hexo injector body_end start --><script data-pjax>function electric_clock_injector_config(){
                var parent_div_git = document.getElementsByClassName('sticky_layout')[0];
                var item_html = '<div class="card-widget card-clock"><div class="card-glass"><div class="card-background"><div class="card-content"><div id="hexo_electric_clock"><img id="card-clock-loading" src="https://cdn.jsdelivr.net/gh/Zfour/Butterfly-clock/clock/images/weather/loading.gif" style="height: 120px; width: 100%;" data-ll-status="loading" class="entered loading"></div></div></div></div></div>';
                console.log('已挂载electric_clock')
                // parent_div_git.innerHTML=item_html+parent_div_git.innerHTML // 无报错，但不影响使用(支持pjax跳转)
                parent_div_git.insertAdjacentHTML("afterbegin",item_html) // 有报错，但不影响使用(支持pjax跳转)
            }if( document.getElementsByClassName('sticky_layout')[0] && (location.pathname ==='/'|| '/' ==='all')){

            electric_clock_injector_config()
        } </script><script src="https://pv.sohu.com/cityjson?ie=utf-8"></script><script data-pjax  src="https://cdn.jsdelivr.net/gh/Zfour/hexo-electric-clock@1.0.6/clock.js"></script><!-- hexo injector body_end end --></body></html>